'use strict';
const db = uniCloud.database()
const collection = db.collection('housedata')
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	const {
		list
	} = event
	// 添加多条
	if (list) {
		const result = await collection.add(list)
		//返回数据给客户端
		return result
	} else {
		const {_id, id ,address ,imgUrl, title, unitPrice} = event
		const result = await collection.add({
			_id,
			id,
			address,
			imgUrl,
			title,
			unitPrice,
		})
		//返回数据给客户端
		return result
	}
};